package com.java.collection;

import java.util.HashMap;
import java.util.Map;

public class CarHashMapDemo {
    public static void main(String[] args) {
        //汽车集合，key司机名字 value汽车对象
        Map<String, Car> cars = new HashMap<>();
        //添加数据
        cars.put("张三",new Car("01","奔驰",100000,"黑色"));
        cars.put("李四",new Car("02","宝马",200000,"白色"));
        cars.put("王五",new Car("03"," Audi",300000,"蓝色"));
        cars.put("赵六",new Car("04","法拉利",400000,"红色"));
        cars.put("钱七",new Car("05","保时捷",500000,"黄色"));

        //通过司机名字查找汽车对象
        Car car = cars.get("钱七");
        System.out.println("找到汽车："+car);
    }
}
